home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 1999 July / Macworld (1999-07).dmg / Serious Software / OpenWorld demo 2.0 / Development / SingleTag / Time / Time.c next >
Text File  |  1999-04-13  |  1KB  |  56 lines

  1. /*  File: Time.c      
  2.     Copyright (c) 1999 Marco Bambini. All rights reserved.
  3.  
  4.     Description: return the current time
  5. */
  6.  
  7. #include "OpenWorld_plugIn.h"
  8. #include "OpenWorld_utils.h"
  9. #include <CodeFragments.h>
  10. #include <Packages.h>
  11. #include <OSUtils.h>
  12.  
  13. Boolean main (dataPtr param)
  14. {    
  15.     switch (param->message)
  16.     {    
  17.         case init_message:
  18.             {
  19.                 param->version=kVersion;
  20.                 param->customData=kUnused;
  21.             }
  22.             break;
  23.             
  24.         case run_message:
  25.             {                    
  26.                 unsigned long time;
  27.                 Str255        resultStr;
  28.                 
  29.                 // get the current date
  30.                 GetDateTime(&time);
  31.                 
  32.                 if (up_strcmp(param->search,"SEC")==NULL) IUTimeString(time,true,resultStr);    // include seconds ex: 12:05:09
  33.                 else IUTimeString(time,false,resultStr);    //without seconds ex: 12:05
  34.                 
  35.                 // allocate the return buffer
  36.                 param->outputText=OW_NewPtr(param,64);
  37.                 
  38.                 if (param->outputText) param->dim=sprintf(param->outputText,"%#s",resultStr);
  39.             }
  40.             break;
  41.         
  42.         case stop_message:
  43.             {
  44.                 // dispose the buffer
  45.                 OW_DisposePtr(param,param->outputText);
  46.             }
  47.             break;
  48.             
  49.         case end_message:
  50.             {
  51.                 // do nothing
  52.             }
  53.             break;
  54.     }
  55.     return kSingleTag;
  56. }